package com.sunny.ynhz.utils;

import android.support.annotation.NonNull;

import java.util.Date;

/**
 * Created by hhh on 2017/12/16.
 */

public class TimeIntervalUtils {
    public static String getTime(String dataFormat,String endTime){
        Date dateLast = TimeFormatUtils.StrToDate(dataFormat);
        long time = dateLast.getTime();
        Date dateLast1 = TimeFormatUtils.StrToDate(endTime);
        long time1 = dateLast1.getTime();

        return getStringTime(time, time1);
    }
    public static String getBetWeenTime(long startTime,long endTime){
        return getStringTime(startTime,endTime);
    }

    @NonNull
    public static String getStringTime(long time, long time1) {
        long l =time1 - time;
        long l1 = l /1000;
        if(l1<=60){
            return l1+"秒";
        }
        else if(l1>60&&l1<3600){
          return l1/60+"分"+l1%60+"秒";
        }
        else if(l1>=3600){
            return l1/3600+"时"+l1%3600/60+"分"+l1%3600%60+"秒";
        }
        return "0秒";
    }

}
